class Solution {
public:
    int firstUniqChar(string s) {
        int cont[26] = { 0 };
        for (int i = 0; i < s.size(); ++i)
        {
            cont[s[i] - 'a']++;
        }
        for (int i = 0; i < s.size(); ++i)
        {
            if (cont[s[i] - 'a'] == 1)
                return i;
        }
        return -1;
    }
};